package agents.curatoragentbehaviours;

import agents.CuratorAgent;
import jade.core.behaviours.CyclicBehaviour;
import jade.lang.acl.ACLMessage;

public class MessageListenerBehaviour extends CyclicBehaviour{
	
	CuratorAgent owner;
	
	public MessageListenerBehaviour(CuratorAgent owner){
		super();
		this.owner = owner;
	}
	@Override
	public void action(){
		ACLMessage msg = myAgent.receive();
		if(msg != null){
			if(msg.getPerformative() == CuratorAgent.GET_ARTIFACTS_SERVICE){
				owner.addBehaviour(new SendArtifactsToTourGuideBehaviour(owner, msg.getSender()));
			}
			else if(msg.getPerformative() == CuratorAgent.GET_INFO_SERVICE){
				owner.addBehaviour(new SendDetailedInfoOfArtifactsBehaviour(owner, msg));
			}
		}
		else{
			block();
		}			
	}
}
